import json
import unittest
import requests
from tpshops.api.login import loginAPI
from parameterized import parameterized
import app

def bilu_data():
    file = app.BASE + "/data/login.json"
    test_data = []
    with open(file,encoding="utf-8") as f:
        json_data = json.load(f)
        for case_data in json_data:
            username = case_data.get("username")
            password = case_data.get("password")
            verify = case_data.get("verify")
            content_type = case_data.get("content_type")
            status = case_data.get("status")
            msg = case_data.get("msg")
            test_data.append((username, password, verify, content_type, status, msg))
            print(test_data)
    return test_data
class Tp(unittest.TestCase):
    def setUp(self):
        self.login_api = loginAPI()

    @parameterized.expand(bilu_data())
    def test_01(self, username, password, verify, content_type, status, msg):
        sepoin = self.login_api.verify()
        self.assertIn(content_type,sepoin.headers.get("Content-Type"))


        sepoin1 = self.login_api.login(username, password, verify)
        self.assertEqual(status, sepoin1.json().get("status"))
        self.assertIn(msg,sepoin1.json().get("msg"))